﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using titi.utilmouse ; 

namespace WindowsFormsApplication1
{
    interface IListItem {
        String getItemType();
        String getText();
        void run(ref MouseOperations mo);
        String getCmd();
        String getCmdAutoItV3();
    }
    class ListItemMouseClick : IListItem
    {
        private MouseOperations.MousePoint mp;
        public ListItemMouseClick(MouseOperations.MousePoint mp)
        {
            this.mp = mp;
            Console.WriteLine(this.getText());
 
        }
        public String getItemType()
        {
            return "mouseclick";
        }
        public String getText()
        {
            return "MouseClick : " + mp.X + "," + mp.Y;
        }
        public void run(ref MouseOperations mo)
        {
            Console.WriteLine(this.getCmd());
            mo.SetCursorPosition(mp);
            mo.MouseLeftClick(mp);
            System.Threading.Thread.Sleep(mo.Delaynum);
        }
        public String getCmd()
        {
            return "AddMouseClick(" + mp.X + "," + mp.Y + ");"; 
        }
        public String getCmdAutoItV3()
        {
        	return "MouseClick(\"left\"," +mp.X + "," + mp.Y + ",1,40);";
        }
    }
    class ListItemClickAndKeyText : IListItem
    {
        private MouseOperations.MousePoint mp;
        private String  s;
        public ListItemClickAndKeyText(MouseOperations.MousePoint mp,String s)
        {
            this.mp = mp;
            this.s = s;
            Console.WriteLine(this.getText());
            
        }
        public String getItemType()
        {
            return "clickandkeytext";
        }
        public String getText()
        {
            return "clickandkeytext : " + mp.ToStringXY() +" " + s;
        }
        public void run(ref MouseOperations mo)
        {
            Console.WriteLine(this.getCmd());
            mo.SetCursorPosition(mp);
            mo.MouseLeftClick(mp);
            System.Threading.Thread.Sleep(mo.Delaynum);

            //System.Windows.Forms.SendKeys.Send(s);
            System.Windows.Forms.SendKeys.SendWait(s);
            System.Threading.Thread.Sleep(mo.Delaynum);
        }
        public String getCmd()
        {
            return "AddClickText(" + mp.X + "," + mp.Y + ",\"" +  s+  "\");";
        }
        public String getCmdAutoItV3()
        {
        	String s1 = "";
        	s1 = "\r\nMouseClick(\"left\"," +mp.X + "," + mp.Y + ",1,40);";
        	s1 = s1 + "\r\nSend(\"" + s + "\");";
 			return s1;        	
        }
    }
    class ListItemClickAndKeyTextEnter : IListItem
    {
        private MouseOperations.MousePoint mp;
        private String s;
        public ListItemClickAndKeyTextEnter(MouseOperations.MousePoint mp, String s)
        {
            this.mp = mp;
            this.s = s;
            Console.WriteLine(this.getText());
        }
        public String getItemType()
        {
            return "clickandkeytextEnter";
        }
        public String getText()
        {
            return  getItemType() + " : " + mp.ToStringXY() + " " + s;
        }
        public void run(ref MouseOperations mo)
        {

            Console.WriteLine(this.getCmd());
            mo.SetCursorPosition(mp);
            mo.MouseLeftClick(mp);
            System.Threading.Thread.Sleep(mo.Delaynum);
            
            System.Windows.Forms.SendKeys.SendWait(s + "{ENTER}");
            //System.Windows.Forms.SendKeys.SendWait(s);
            System.Threading.Thread.Sleep(mo.Delaynum);
        }
        public String getCmd()
        {
            return "AddClickTextEnter(" + mp.X + "," + mp.Y + ",\"" + s + "\");";
        }
        public String getCmdAutoItV3()
        {
        	String s1 = "";
        	s1 = "\r\nMouseClick(\"left\"," +mp.X + "," + mp.Y + ",1,40);";
        	s1 = s1 + "\r\nSend(\"" + s + "{ENTER}\");";   
			return s1;        	
        }
    }


}
